#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char str[27];
int len;
char stack[27];
int top = 0;
int index = 0;

int IsNum(char c)
{
	if (c >= '0' && c <= '9' || c == '.')
		return 1;
	else
		return 0;
}

int compare(char a, char b)
{
	if (b == ')')return 1;
	if (a == '(' || b == '(')return 0;
	switch (b)
	{
	case '+':
	case '-':
		return 1;
	case '*':
	case '/':
		switch (a) {
		case '+':
		case '-':
			return 0;
		case '*':
		case '/':
			return 1;
		}
	}
}

int ZhengFu(char a)
{
	if (a == '+' || a == '-')
		return 1;
	else
		return 0;
}

void Mainfun()
{
	int space = 0;
	for (index = 0; index < len; index++)
	{
		if (IsNum(str[index]))
		{
			if (space == 1)
			{
				printf(" ");
				space = 0;
			}
			printf("%c", str[index]);
		}
		else if (ZhengFu(str[index]) && ((index == 0) || (IsNum(str[index - 1]) != 1 && str[index - 1] != ')')))
		{
			if (str[index] == '-')
			{
				if (space == 1)
				{
					printf(" ");
					space = 0;
				}
				printf("%c", str[index]);
			}
		}
		else
		{
			if (top != 0)
			{
				if (str[index] == ')')
				{
					while (top--)
					{
						if (stack[top] == '(')break;
						else printf(" %c", stack[top]);
					}
				}
				else
				{
					while (top != 0)
					{
						if (compare(stack[top - 1], str[index]))
							printf(" %c", stack[--top]);
						else
							break;
					}
					stack[top++] = str[index];
				}
			}
			else
			{
				stack[top++] = str[index];
			}
			int j;
			for (j = 0; j < top; j++)
				if (stack[j] != '(')
				{
					space = 1;
					break;
				}
		}
	}
	while (top != 0)
		printf(" %c", stack[--top]);
}

int main()
{
	scanf("%s", str);
	len = strlen(str);

	Mainfun();
	return 0;
}